package com.example.demo.api;

import com.example.demo.model.ApiResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.Date;

/**
 * @author hankChan
 *         2018/2/3 0003.
 */
@Validated
@RestController
public class RequestParamValidateAPIs {


    @RequestMapping(value = "/api/validate/request_param",
            method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public ApiResult param(
            @Max(value = 1001, message = "id取值为1-1001")
            @Min(value = 1, message = "id取值为1-1001")
            @RequestParam("id") Integer id) {
        return ApiResult.prepare().success(new Date().getTime());
    }
}
